package com.majsubtense.main;

import com.majsubtense.core.achievements.Achievement;
import com.majsubtense.core.achievements.AchievementController;
import com.majsubtense.core.components.UI;
import com.majsubtense.core.events.*;

import javafx.application.Application;
import javafx.stage.Stage;

public class SandboxApp extends Application {
    private final float width = 600;
    private final float height = 400;
    private static Stage stage;

    public SandboxApp() {
        UI.addListener(new EventHandler<>(
                GameControlEvent.GAME_QUIT,
                gameControlEvent -> stage.close()
        ));
    }

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        stage = primaryStage;
        primaryStage.setTitle("JavaFX Window");
        primaryStage.setWidth(width + 18);
        primaryStage.setHeight(height + 47);
        primaryStage.setResizable(false);
        primaryStage.show();

        GameController.initialize();
        AchievementController.initialize();
    }

    public static Stage getStage() {
        return stage;
    }
}
